const myStorage = {
  //存储
  set(key: string, value: any) {
    localStorage.setItem(key, JSON.stringify(value));
  },
  //取出数据
  get(key: string) {
    try {
      const value = localStorage.getItem(key);
      if (value === null || value === undefined || value === '') {
        return null;
      } else {
        return JSON.parse(value);
      }
    } catch (err) {
      return null;
    }
  },
  //删除数据
  remove(key: string) {
    localStorage.removeItem(key);
  },

  clear() {
    localStorage.clear();
  },
};

export default myStorage;
